package org.huatek.anders.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
 * @author anders
 * @date 2018-12-20 16:44
 **/
@Configuration
public class RedisTemplateConfig {

    private final RedisTemplate redisTemplate;
    @Autowired
    public RedisTemplateConfig(RedisTemplate redisTemplate){
        this.redisTemplate = redisTemplate;
    }

    @Bean
    public RedisTemplate redisTemplateInit() {
        //设置序列化Key的实例化对象
        redisTemplate.setKeySerializer(new StringRedisSerializer());
        //设置序列化Value的实例化对象
        /// redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
        return redisTemplate;
    }

}
